<?php
/**
 * Created by PhpStorm.
 * User: Anjou
 * Date: 2017/4/24
 * Time: 16:01
 */
/**多个数组根据相同键名合并
 *
 **/

function hebingarr($arr,$arr2,$arr3,$val='',$val2='',$val3=''){
    $idNum = count($arr);
    $branchNum = count($arr2);
    $textNum = count($arr3);
    $countMax = ($idNum > $branchNum ? $idNum : $branchNum) > $textNum ? ($idNum > $branchNum ? $idNum : $branchNum) : $textNum;
    $result = array();
    for($i=0; $i < $countMax ; $i++){
        $temp = array(
            $val?$val:'icon_img' => isset($arr[$i]) ? $arr[$i] : '',
            $val2?$val2:'icon_name' =>  isset($arr2[$i]) ? $arr2[$i] : '',
            $val3?$val3:'icon_url' =>  isset($arr3[$i]) ? $arr3[$i] : ''
        );
        $result[] = $temp;
    }
    return $result;
}